package MazeGenProject;


import java.io.IOException;

import javax.swing.JFileChooser;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JToolBar;

import org.jhotdraw.application.DrawApplication;
import org.jhotdraw.framework.Drawing;
import org.jhotdraw.framework.DrawingView;
import org.jhotdraw.framework.Tool;
import org.jhotdraw.standard.CreationTool;
import org.jhotdraw.util.StorageFormat;


public class MazeGen extends DrawApplication 
{

	private CreationTool lineDraw;
	private CreationTool ranMaze;
	private CreationTool solveMaze;
	private CreationTool _manSolve;
	private GridDrawing _gridDrawing;
	public RandomMaze ranMazeDrawing;

	public MazeGen()
	{
		super("Maze Generator");
	}
	
	public void newWindow(Drawing initialDrawing) {
		MazeGen window = new MazeGen();
		if (initialDrawing == null) {
			window.open();
		}
		else {
			window.open(window.createDrawingView(initialDrawing));
		}
	}

	protected void createTools(JToolBar palette) 
	{				
		ranMazeDrawing = new RandomMaze(_gridDrawing, 20, 20);

		super.createTools(palette);
		lineDraw = new WallTool(this, new WallFigure(_gridDrawing));
		ranMaze = new RandomMazeTool(this, ranMazeDrawing);
		//solveMaze = new SolveMazeTool(this,new SolveMaze(_gridDrawing, ranMazeDrawing));
		_manSolve = new SolveLineTool(this, new SolveLineFigure(_gridDrawing));
		palette.add(createToolButton(IMAGES+"LINE", "Wall Tool", lineDraw));
		palette.add(createToolButton(IMAGES+"SCRIBBL", "Random Maze", ranMaze));
		//palette.add(createToolButton(IMAGES+"OCONN", "Solve Maze", solveMaze));
		palette.add(createToolButton(IMAGES+"CONN", "Solve Tool", _manSolve));
	}
	
	@Override
	protected Drawing createDrawing() {
		return _gridDrawing = new GridDrawing(this.getDrawingViewSize());
	}
	
	public GridDrawing getDrawing(){
		return _gridDrawing;
	}
	
	
	@Override
	protected void createMenus(JMenuBar mb) {
		addMenuIfPossible(mb, createFileMenu());
		addMenuIfPossible(mb, createEditMenu());
	}
	
	@Override
	public void toolDone() {
		System.out.println("ToolDone");
	}
	
	
}

